<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
        }
        .box{
            border: 1px solid black;
            padding: 30px;
            margin: 10px 0px;
        }
    </style>
</head>
<body>
    <div id="app" class="box">
        <h4>组件A</h4>
        <comp-b></comp-b>
        <comp-c></comp-c>
    </div>
    <script type="module"> 
        import { createApp } from "../../assets/vue3/vue.esm-browser.js";
        // 嵌套生命周期以  beforeMount  和 mounted 为执行分界点
        const app = createApp({
            beforeMount () {
                console.log("==>A - beforeMount")
            },
            mounted () {
                console.log("==>A - mounted")
            },
        })
        app.component("CompD",{
            template:`
                <div class="box">
                    <h4>组件D</h4>
                </div>
            `,
            beforeMount () {
                console.log("======>D - beforeMount")
            },
            mounted () {
                console.log("======>D - mounted")
            },
        })
        app.component("CompE",{
            template:`
                <div class="box">
                    <h4>组件E</h4>
                </div>
            `,
            beforeMount () {
                console.log("======>E - beforeMount")
            },
            mounted () {
                console.log("======>E - mounted")
            },
        })
        app.component("CompB",{
            template:`
                <div class="box">
                    <h4>组件B</h4>
                    <comp-d></comp-d>
                    <comp-e></comp-e>
                </div>
            `,
            beforeMount () {
                console.log("====>B - beforeMount")
            },
            mounted () {
                console.log("====>B - mounted")
            },
        })
        app.component("CompC",{
            template:`
                <div class="box">
                    <h4>组件C</h4>
                </div>
            `,
            beforeMount () {
                console.log("====>C - beforeMount")
            },
            mounted () {
                console.log("====>C - mounted")
            },
        })
        
        app.mount("#app")
    </script>
</body>
</html>